Page({
	data: {
		fixedBottomHeight: 0,
		checkboxIconColor: "rgba(0, 0, 0, .35)",
		checkboxIconSelectedColor: "#0BEDA8  ",
		List: [{
			title: "层级1",
			isOpen: true,
			level: 1,
			children: [{
        title: "层级1-1",
					isOpen: true,
					level: 2,
					id: 1,
					children: [{
						title: "level 3-1",
						level: 3,
					}]
				},
				{
          title: "层级2-1",
					isOpen: true,
					level: 2,
					id: 2,
					children: [{
						title: "level 3-3",
						level: 3,
					}]
				}
			]
		}]
	},

	calcFixedHeight() {
		var that = this;
		var query = wx.createSelectorQuery();
		query.select("#appFixedBottom").boundingClientRect(function (rect) {
			if (rect) {
				that.setData({
					fixedBottomHeight: rect.height
				})
			}
		}).exec();
	},
	kindToggle(e) {
		let that = this
		let List = that.data.List
		let level = e.currentTarget.dataset.level
		let id = e.currentTarget.dataset.id
		console.log('level', level);
		console.log('id', id);
		if (level == 1) {
			List.forEach(item => {
				item.isOpen = !item.isOpen
			});
		}
		if (level == 2) {
			List.forEach(item => {
				item.children.forEach((ite, index) => {
					if (id == index + 1) {
						ite.isOpen = !ite.isOpen
					}
				})
			});
		}
		this.setData({
			List
		})
	},
	onLoad: function (options) {

	},

	onReady: function () {

	},

	onShow: function () {
		this.calcFixedHeight()
	},

	onHide: function () {

	},

	onUnload: function () {

	},

	onPullDownRefresh: function () {

	},

	onReachBottom: function () {

	},

	onShareAppMessage: function () {

	}
})